// ignore_for_file: file_names, must_be_immutable, constant_identifier_names, slash_for_doc_comments, avoid_unnecessary_containers, prefer_const_constructors, unnecessary_cast, sized_box_for_whitespace, prefer_function_declarations_over_variables, overridden_fields, annotate_overrides, prefer_const_literals_to_create_immutables, unnecessary_null_comparison, deprecated_member_use

import 'package:flutter/material.dart';

///
class FFGotoManager {
  // 单例公开访问点
  factory FFGotoManager() => _sharedInstance();

  // 静态、同步、私有访问点
  static FFGotoManager _sharedInstance() {
    return _instance;
  }

  // 静态私有成员，没有初始化
  static final FFGotoManager _instance = FFGotoManager._();

  // 私有构造函数
  FFGotoManager._() {}

  IFFGoto? iffGoto;

  Future<bool> gotoNextPage(
    BuildContext context,
    Widget? pageWidget,
    String? routerName, {
    bool? ignore = false,
  }) async {
    return await iffGoto?.goNextPage(context, pageWidget, routerName, ignore: ignore) ?? true;
  }

  Future<bool> gotoPreviousPage(
    BuildContext context, {
    bool? ignore = false,
  }) async {
    return await iffGoto?.goPreviousPage(context, ignore: ignore) ?? true;
  }
}

abstract class IFFGoto {
  Future<bool> goNextPage(
    BuildContext context,
    Widget? pageWidget,
    String? routerName, {
    bool? ignore = false,
  });

  Future<bool> goPreviousPage(
    BuildContext context, {
    bool? ignore = false,
  });
}
